<?php
namespace app\admin\controller;
use app\admin\model\AboutModel;
class About extends BaseController
{
     public function __construct()
     {
        parent::__construct();
        $this->about = new AboutModel();
     }
	 //关于我们显示
	 public function index(){
		$list = $this->about->index();
        $page = $list->render();
        $count = count($list);
        $this->assign('list',$list);
        $this->assign('page',$page);
        $this->assign('count',$count);
        return view('about/index');
	 }
	 //关于我们添加
	  public function add(){
		 if(request()->isAjax())
         {
            $res = $this->about->add();
            if($res)
            {
                return ['code'=>'1','message'=>'添加成功'];
            }else{
                return ['code'=>'0','message'=>'添加失败'];
            }
         }
        return view('about/add');
	  }
	  //关于我们修改
	  public function edit()
      {
        if(request()->isAjax())
        {
            $res = $this->about->edit();
            if($res)
            {
                return ['code'=>'1','message'=>'修改成功'];
            }else{
                return ['code'=>'0','message'=>'修改失败'];
            }
        }
        $id = input('id');
        $res = $this->about->getOneId($id);
        $this->assign('data',$res);
        return view('about/edit');
     }
	 //关于我们删除
	 public function del()
    {
        $res = $this->about->del();
        if($res)
        {
            return ['code'=>'1','message'=>'删除成功'];
        }else{
            return ['code'=>'0','message'=>'删除失败'];
        }
    }
	 //关于我们删除(全选删除)
	 public function dell()
    {
        $res = $this->about->dell();
        if($res)
        {
            return ['code'=>'1','message'=>'删除成功'];
        }else{
            return ['code'=>'0','message'=>'删除失败'];
        }
    }
}
?>